import requests
import bs4
from bs4 import BeautifulSoup
import re
url0='https://bbs.bccn.net/forum-246-1.html'
for i in range(1,11):
        url=url0.replace(url0[-6],str(i))
        headers={'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36 Edg/99.0.1150.46'}
#伪装浏览器
        res=requests.get(url,headers=headers)
        res.encoding=res.apparent_encoding#直接读取网页编码
        soup=BeautifulSoup(res.text,'html.parser')
#print(soup)
        tags=soup.find_all('td',{'class':'title'})
        for i in tags:
                a=i.text
                b=re.sub(u"\\[.*?]","",a)
                c=b.strip()
                #b=a.replace('[结]','')
                #c=b.replace('[ 2 ]','')
                #d=c.strip()#表示去掉空格
                print(c)
                if c=='主题'
        
